#!bin/bash
###编写人：杨政壹
###编写日期：2024/07/11
###版本功能：使用sqoop实现Oracle跨库到hive的全量抽取
q="jdbc:oracle:thin:@192.168.3.249:1521/ORCL"
w="xm02"
e="123456"
r1="ODS_LOAN_APFO"
r2="ODS_CONT_INFO"
t="xm02ods"
echo"-------编写sqoop语句，进行贷款申请表的数据全量抽取---"
sqoop import \
--hive-import \
--connect ${q} \
--username ${w} \
--password ${e} \
--table ${r1} \
--hive-database ${t} \
--fields-terminated-by ',' -m 1
echo $?
c1=`hive -e "set hive.exec.mode.local.auto=true;select count(1) from ${t}.${r1};"`
echo"---------贷款申请表数据已抽取完成，一共抽取了${c1}条数据--------"
echo"------------------------------------------------------------"
echo"-------编写sqoop语句，进行合同信息表的数据全量抽取---"
sqoop import \
--hive-import \
--connect ${q} \
--username ${w} \
--password ${e} \
--table ${r2} \
--hive-database ${t} \
--fields-terminated-by ',' -m 1
echo $?
c2=`hive -e "set hive.exec.mode.local.auto=true;select count(1) from ${t}.${r2};"`
echo"---------合同信息表数据已抽取完成，一共抽取了${c2}条数据--------"